1. Field of the Invention
This invention relates in general to generating Web content, and in particular, to a method for enabling multiple code generators in a translator-based embedded scripting system.
2. Description of Related Art
With the fast growing popularity of the Internet and the World Wide Web (also known as xe2x80x9cWWWxe2x80x9d or the xe2x80x9cWebxe2x80x9d), there is also a fast growing demand for Web development tools. A number of different tools are available, including HTML translators, Java interpreters, JavaScript translators, etc.
A translator-based embedded scripting environment usually converts the original input source containing embedded script into an equivalent script format first, such that a script engine only has to deal with a final source file. For example, when the original input source is HTML text, with or without embedded Java source, a JavaSoft Pagecompile(trademark) translator usually converts the original input source into an equivalent Java source file, so that a Java Virtual Machine only has to interpret the Java source and not the HTML text.
However, this approach fails when there is a need to have more than one translator to process the original input source. For example, if the original input source includes non-HTML text and/or non-Java source, such as JavaScript, NetRexx, etc., a JavaSoft Pagecompile(trademark) translator cannot convert the original input source into its equivalent Java source; instead, another translation from JavaScript, NetRexx, etc., into Java source must occur first.
The present invention solves this problem by introducing a method to allow the use of multiple code generators with an original input source.
To overcome the limitations in the prior art described above, and to overcome other limitations that will become apparent upon reading and understanding the present specification, the present invention discloses a method, apparatus, and article of manufacture for providing a translator-based embedded scripting environment that includes multiple translators, interpreters, or code generators for use with a single original input source. The original input source contains programming statements in multiple languages, and is split into multiple intermediate sources. One of the intermediate sources contains statements in a first programming language as well as placeholders identifying the locations of statements in the original input source in a second programming language. This intermediate source is translated into a class definition, wherein the placeholders are translated into file input/operations that write the statements in the original input source in the second programming language to an output destination. Another of the intermediate sources is translated into statements that instantiate the class definition as an object and then invoke the methods of the instantiated object in order to maintain a sequence of execution specified in the original input source.